import { PickHandle } from "../type";

const groupPickHandle: PickHandle = {

	ruleType: "group",

	canCount: true,

	isNode: false,

	// [canCount=false]
	onlyEnter: (save, origin, str, index, char, length) => {
	},

	enter: (origin, hasRange) => {
		// ruleIndexStack
		const ruleChildren = origin.ruleIndexStack.infoCheck.children;
		origin.ruleIndexStack.push(0, ruleChildren);
		// catchInfo
		if (hasRange) {
			origin.catchBuffer.EnterList();
		}
		origin.catchBuffer.EnterList();
	},

	// [canCount=true]
	newExit: (enterBranch) => {
		// catchInfo
		enterBranch.catchBuffer.EnterList();
		enterBranch.catchBuffer.Back();
	},

	// [canCount=true]
	reenter: (enterBranch) => {
		// ruleIndexStack
		const ruleChildren = enterBranch.ruleIndexStack.infoCheck.children;
		enterBranch.ruleIndexStack.push(0, ruleChildren);
		// catchInfo
		enterBranch.catchBuffer.Back();
		enterBranch.catchBuffer.EnterList();
	},

	exit: (origin, hasRange) => {
		// catchInfo
		if (hasRange) {
			origin.catchBuffer.Back();
		}
		origin.catchBuffer.Back();
	},

	// [isNode=true]
	noodHnalde: (save, origin, rule, str, index, char, length) => {
		return false;
	},

};


export default groupPickHandle;
